import os
import json
import requests
from wxpy import *
import yaml
from redis import StrictRedis,ConnectionPool
CONF_PATH=os.path.join(os.path.dirname(__file__),'conf')

#服务器配置数据
def init_config(CONF_PATH):
    file_data = ''
    CONF_PATH = os.path.join(CONF_PATH, 'conf.yaml')
    with open(CONF_PATH, 'r', encoding='utf8') as r:
        file_data = r.read()

    config = yaml.load(file_data, Loader=yaml.FullLoader)
    return config


config=init_config(CONF_PATH)
# print(config)
# print(config['redis']['host'])
# db_handler=DB_handler(config)

# pool=ConnectionPool(host=config['redis']['host'],port=config['redis']['port'],db=config['redis']['db'],password=config['redis']['password'])
pool=ConnectionPool(host='106.12.89.171',port=6379,db=0,password='zz123456')
rs=StrictRedis(connection_pool=pool)

# rs.set('test1','hahahaha')
keys=rs.keys()
# rs.delete('test1')
# rs.flushall()

# print(keys)

# for k in keys:
#     sdata=rs.get(k)
#     d=sdata.decode()
#     print(d)

    # data=json.loads(d)
    # print(data)
    # data=eval(sdata.decode())
    # print(type(data),data)
    # print(sdata)